
import json
from pathlib import Path

_base_path = Path(r"Sentry3-MindPlus")

esp32_path = list(_base_path.rglob("esp32.json"))[0]
_menus_path = esp32_path.parent
with open(esp32_path, encoding='utf-8') as f:
    base_menu = json.load(f)

for file in _menus_path.rglob("*.json"):
    if file.stem == "esp32":
        continue
    with open(file, encoding='utf-8') as f:
        menu = json.load(f)
    MODE = menu["MODE"]

    output = base_menu.copy()
    output["MODE"] = MODE
    with open(file, "w", encoding='utf-8') as f:
        json.dump(output, f, indent=4, ensure_ascii=False)